<?
 //wanneer ingelogd
if($_GET['loginnow'])
{
  $username = $_POST['username'];
 $password = $_POST['password'];
 
 $query = "SELECT * FROM klant WHERE username = '".$username."' AND password = '" . $password."'";
  $result = mysql_query($query);

 if(mysql_num_rows($result)>0)
 {
  $ip=$_SERVER['REMOTE_ADDR'];
  $date = date("m-d-y");
  $time = date("H:i:s");
  
  $query2 = "SELECT * FROM sessie WHERE ip = '".$ip."'";
  $result2 = mysql_query($query2);
  
  if(mysql_num_rows($result2)==0)
  {
   $row = mysql_fetch_array($result);
   $klantid = $row['id'];
   mysql_query("INSERT INTO sessie (idklant, ip, date, timestamp)
   VALUES('".$klantid."', '".$ip."', '".$date."', '".$time."')");
  
   print "<META HTTP-EQUIV=\"refresh\" CONTENT=1 URL=index.php?page=account >";
   print "Succesvol ingelogd.<br>";
   print "<blink>U wordt doorgestuurd...</blink>";
  }
  else
  {
   header( 'Location: index.php?page=account');
  }
 }
}

//uitloggen
if($_GET['logout']==1)
{
  $ip=$_SERVER['REMOTE_ADDR'];
  $query = mysql_query("SELECT * FROM sessie WHERE ip = '".$ip."'");
  while($result = mysql_fetch_array($query))
  {
   mysql_query("DELETE FROM sessie WHERE id = '".$result['id']."'");
   
   print "<META HTTP-EQUIV=\"refresh\" CONTENT=1 URL=index.php >";
   print "Succesvol uitgelogd.<br>";
   print "<blink>U wordt doorgestuurd...</blink>";

  }
}
?>      
<form action="index.php?page=login&loginnow=1" method="post">
 <br><br><br><br><br><br>
     Inloggen.
   	 Log hier met de gebruikersnaam en <br>
  wachtwoord die u via de mail hebt ontvangen.</p>
    
            
           
  <br>
  <br>
  Inloggegevens:
       
       <br>
  username: 
  <input name="username" title="Voer hier de gebruikersnaam in." type="text" maxlength="255" value=""/> 
      
                <br>
  password: 
  <input name="password" title="Voer hier de wachtwoord in." type="password" maxlength="255" value=""/>
  <br>
  <br> 
     
   
            
     
                <input type="hidden" name="SubmitCheck" value="sent" />
                <input type="Submit" name="Form1_Submit" value="Inloggen" />
    
</form>
 <br><br><br><br><br><br>